import { Component, OnInit, Input, ViewChild, TemplateRef } from '@angular/core'
import { IBaseInfoColumn } from '@shared/interfaces/baseInfo'
import { IDeposit } from '@shared/interfaces/deposit'
import { DetailBaseClass } from '@shared/classes/DetailBaseClass'
import { I18NService } from '@core'
import { Router, ActivatedRoute } from '@angular/router'
import { PageService } from '@shared/services/page.service'

@Component({
  selector: 'app-deposit-task-restitution-detail',
  templateUrl: './restitution.component.html',
})
export class DepositTaskRestitutionDetailComponent extends DetailBaseClass<IDeposit> implements OnInit {
  @Input() restitutionDetail: IDeposit
  @ViewChild('tpDepositAmt') tpDepositAmt: TemplateRef<void>
  @ViewChild('tpTotalAmt') tpTotalAmt: TemplateRef<void>
  firstColumns: IBaseInfoColumn[]
  secondColumns: IBaseInfoColumn[]

  constructor(
    public i18n: I18NService,
    public router: Router,
    public route: ActivatedRoute,
    public pageService: PageService,
  ) {
    super(pageService)
  }

  ngOnInit() {
    this.detailData = this.restitutionDetail
    this.initFirstColumns()
    this.initSecondColumns()
    this.initColumns()
  }

  initFirstColumns(): void {
    this.firstColumns = [
      {
        span: 8,
        index: 'operationID',
        label: '操作编号',
        labelI18n: 'OPERATION.DEPOSIT.OPERATION_ID',
      },
      {
        span: 8,
        label: '目标金额',
        labelI18n: 'OPERATION.DEPOSIT.TARGET_AMT',
        displayTemplate: this.tpDepositAmt,
      },
      {
        span: 8,
        label: '门店总金额',
        labelI18n: 'OPERATION.DEPOSIT.TOTAL_AMT',
        displayTemplate: this.tpTotalAmt,
      }
    ]
  }

  initSecondColumns(): void {
    this.secondColumns = [
      {
        span: 24,
        index: 'remark',
        label: '备注',
        labelI18n: 'GENERAL.INFO.REMARK',
      },
    ]
  }
}
